<?php
#####################################
# * @Author: lehieu008              #
# * @Email: lehieu008@gmail.com     #
# * @Copyright: 2008 - 2010         #
#####################################
if(!defined('BASEPATH'))exit('No direct script access allowed');
class Banner_module extends Controller
{
    function __construct()
    {
        parent::Controller();
    }
    
    function index($position = 1, $limit = 1, $random = true)
    {
        if($random == true)
        {
            $data['banners'] = $this->global_model->fetch("SELECT banID, banTitle, banBanner, banDirBanner, banCode, banTarget, banPosition FROM {PRE}banner WHERE banPosition = $position AND banStatus = 1 AND banExpireDate >= ".time()." ORDER BY RAND() LIMIT 0,$limit");
        }
        else
        {
            $data['banners'] = $this->global_model->fetch("SELECT banID, banTitle, banBanner, banDirBanner, banCode, banTarget, banPosition FROM {PRE}banner WHERE banPosition = $position AND banStatus = 1 AND banExpireDate >= ".time()." ORDER BY banOrder LIMIT 0,$limit", true);
        }
        #Load View
        $this->load->view('banner/defaults', $data);
    }
}